<template>
  <uni-nav-bar title="首页" color="#333" :border="false" statusBar></uni-nav-bar>
  <!--  <view class="package_sale space-between" v-if="userInfo.userInfor">
    <view class="center top">
      <image :src="userInfo.userInfor.avatar?userInfo.userInfor.avatar:avatar" mode=""></image>
      <view>{{userInfo.userInfor.name?userInfo.userInfor.name:'用户名'}}</view>
    </view>
    <uni-icons type="scan" size="30" @click="scanCode()"></uni-icons>
  </view> -->
  <!-- 工作状态 -->
  <Working></Working>
  <!-- 切换 -->
  <z-tabs ref="tabs" :list="list" :current="current" @change="tabsChange" inactive-color="#333" />
  <!-- 统计 -->
  <Statistics v-if="current===0||current===1" ref="count" @confirm="confirm"></Statistics>
  <!-- 加注量 -->
  <Fill v-if="current===0" :fillList="information.informationMine"></Fill>
  <!-- 收益 -->
  <Income v-if="current===0" :income="information.informationMine"></Income>
  <!-- 新增车友 -->
  <NewFriend v-if="current===0" :newFriend="information.informationMine"></NewFriend>
  <!-- 排行榜 -->
  <PieChart v-if="current===1" :pieChart="information.informationGroup" ref="chart"></PieChart>
  <!-- 活动 -->
  <ActivityList v-if="current===2" :activityList="information.informationMovable"></ActivityList>
  <!-- 公告列表 -->
  <Notice v-if="current===3"></Notice>
  <view class="lis">
    <uni-fab :pattern="pattern" :content="content" horizontal="right" vertical="bottom" direction="vertical"
      @trigger="trigger"></uni-fab>
  </view>
  <!-- 未登录弹框 -->
  <Unlisted></Unlisted>
  <!-- <DragImg type="message" :img_sub="smallBell" @btnClick="navTo('Sale/Information/newList')"></DragImg> -->
  <SaleButtom active="0"></SaleButtom>
</template>

<script setup lang="ts">
  import { ref } from 'vue';
  import { navTo } from '@/utils/navigator';
  import SaleButtom from '@c/pobulic/saleButtom.vue';
  import Working from '@c/earthPushing/index/working.vue';
  import Unlisted from '@c/earthPushing/common/unlisted.vue';
  import Statistics from '@c/earthPushing/index/statistics.vue';
  import ActivityList from '@c/earthPushing/list/activityList.vue';
  import Fill from '@c/earthPushing/index/fill.vue';
  import Income from '@c/earthPushing/index/income.vue';
  import NewFriend from '@c/earthPushing/index/newFriend.vue';
  import { onPullDownRefresh } from '@dcloudio/uni-app';
  import PieChart from '@c/earthPushing/index/pieChart.vue';
  import Notice from '@c/earthPushing/index/notice.vue';
  // import DragImg from '@c/drag-button/drag-img';
  import { smallBell, takeaway } from '@/utils/Statics';
  import { useUserInformation } from '@/stores/earthPushing/userSale';
  import { DataStore } from '@/stores/earthPushing/data';
  const userInfo = useUserInformation();
  const information = DataStore()
  const pattern = {
    color: '#7A7E83',
    backgroundColor: '#fff',
    selectedColor: '#007AFF',
    buttonColor: '#007AFF',
    iconColor: '#fff'
  }
  const content = [{
    iconPath: takeaway,
    selectedIconPath: takeaway,
    text: '新增外卖',
    active: false
  },
  {
    iconPath: smallBell,
    selectedIconPath: smallBell,
    text: '消息通知',
    active: false
  }
  ]
  const list = [{ name: '个人' }, { name: '团队' }, { name: '活动' }, { name: '公告' }]
  const current = ref(0)
  const tabs = ref(null)
  const count = ref(null)
  const chart = ref(null)
  userInfo.getUserInfo();
  information.informationMY('today')
  information.informationTeam('today')
  information.informationActive()
  onPullDownRefresh(() => {
    userInfo.getUserInfo();
    information.informationMY('today')
    information.informationTeam('today')
    information.informationActive()
    uni.stopPullDownRefresh();
  })

  //tabs通知swiper切换
  function tabsChange(index : number) {
    current.value = index;
    if (index === 0 || index === 1 && count.value) {
      count.value.blockedOut(index)
    }
  }
  function confirm() {
    if (chart.value) {
      chart.value.getServerData()
    }
  }
  function trigger(e : any) {
    console.log(e.index)
    switch (e.index) {
      case 0:
        navTo('Sale/takeaway/addNew')
        break;
      case 1:
        navTo('Sale/Information/newList')
        break;
    }
  }
</script>
<style scoped lang="less">
  .top {
    image {
      width: 80rpx;
      height: 80rpx;
      border-radius: 50%;
      margin-right: 15rpx;
    }
  }
</style>
<style>
  .lis>>>.uni-fab--rightBottom {
    bottom: 80px;
  }

  .lis>>>.uni-fab__circle--rightBottom {
    bottom: 80px;
  }

  .lis>>>.uni-fab__content--other-platform {
    box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.3);
  }
</style>